Test-Series - programming logic

Test Number 5/15

Q: Preprocessor feature that supplies line numbers and file names to the compiler is called?
A. Line
B. Concatenation
C. macro substitution
D. Selective inclusion
Solution: The correct answer is:Line
Q: Stuti is making a questionnaire of True-false questions. She wants to define a data-type that stores the response of the candidate for the question. What is the most-suited data type for this purpose?
A. character
B. integer
C. boolean
D. float
Solution: The correct answer is:boolean
Q: What is the output of this C code?

#define a 20
int main()
{
const int a=50;
printf("a=%d
",a);
}
A. a = 50
B. Run time error
C. Compilation Error
D. a = 20
Solution: The correct answer is:Compilation Error
Q: What is the output of this C code?

int main()
{
int var =010;
printf("%d, var");
}
A. 9
B. 10
C. 8
D. 2
Solution: The correct answer is: 8
Q: Prashant takes as input 2 integer numbers, a and b, whose value can be between 0 and 127. He stores them as 7-bit numbers. He writes the following code to process these numbers to produce a third number c.

c = a - b 

In how many minimum bits should Prashant store c?
A. 9 bits
B. 8 bits
C. 7 bits
D. 6 bits
Solution: The correct answer is: 8 bits
Q: What will be the output of the following code :

main()
{ int i;
if(true)
   printf("work");
  else
printf("not work");
return 0;
}
A. compiler error
B. not work
C. work
D. runtime error
Solution: The correct answer is: work
Q: Which of the following are C preprocessors?
A. #ifdef
B. #define
C. #endif
D. All of the mentioned.
Solution: The correct answer is:
All of the mentioned.
Q: Which of the following is not a valid variable name declaration?
A. int a_3;
B. int _3a
C. int 3_a;
D. int _a3;
Solution: The correct answer is:int 3_a;
Q: Which of the following is not a valid C variable name?
A. int number;
B. int variable_count;
C. float rate;
D. int $main;
Solution: The correct answer is: int $main;
Q: What will be the output of the following code statements?

//Assume all header files are included

integer a=50. b=25, c=0
print (a>45 OR b>50 AND c>10)
A. 1
B. -1
C. 2
D. 0
Solution: The correct answer is:
1

You Have Score    /10